#include "HanoiArthur.h"
#include <GL/glu.h>
#include "gllib/Objects.h"

static void desenhaBase()
{
	glColor3f(0.82,0.41,0.13);
	gllibEightDots(-3.5,0,0.75,3.5,0,0.75,3.5,0,-0.75,-3.5,0,-0.75, -3,0.25,0.25,3,0.25,0.25,3,0.25,-0.25,-3,0.25,-0.25);
	glPushMatrix();
	glTranslatef(-2, 1, 0);
	gllibCylinder(0.2,1.5,10);
	glPopMatrix();
	glPushMatrix();
	glTranslatef(0, 1, 0);
	gllibCylinder(0.2,1.5,10);
	glPopMatrix();
	glPushMatrix();
	glTranslatef(2, 1, 0);
	gllibCylinder(0.2,1.5,10);
	glPopMatrix();
}

static void desenhaDisco(float raio, char pino, char altura)
{
	float x;
	switch (pino)
	{
		case 1:
		{
			x=-2.0;
			break;
		}
		case 2:
		{
			x=0.0;
			break;
		}
		case 3:
		{
			x=2.0;
			break;
		}
		default:
		{
			x=0;
			break;
		}
	}

	glPushMatrix();
	glColor3f(raio*raio, raio, raio*raio*raio);
	glTranslatef(x, 0.25*(float)altura+0.375, 0);
	gllibCylinder(raio,0.25,20);
	glPopMatrix();
}

void HanoiArthur::draw()
{
	desenhaBase();

	desenhaDisco(0.8,1,0);
	desenhaDisco(0.7,1,1);
	desenhaDisco(0.5,1,2);

	desenhaDisco(0.6,2,0);
        desenhaDisco(0.4,2,1);

	desenhaDisco(0.9,3,0);
}
